package com.ks.comment.controller;


import com.ks.comment.controller.dto.CommentListRequest;
import com.ks.comment.controller.dto.CommentRequest;
import com.ks.comment.entity.ZpzComment;
import com.ks.comment.service.IZpzCommentService;
import com.ks.core.base._ControllerBase;
import com.ks.core.core.Result;
import com.ks.core.dto.SearchCriteriaBase;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 信息点赞/踩日志表 前端控制器
 * </p>
 *
 * @author kingdee123
 * @since 2020-12-18
 */
@RestController
@RequestMapping("/zpzComment")
@Api(value = "转评赞系统信息评价清单表", description = "转评赞系统信息评价清单表")
public class ZpzCommentController extends _ControllerBase {

    @Autowired
    private IZpzCommentService zpzCommentService;


    @PostMapping("/addComment")
    @ApiOperation(value = "转评赞系统添加评价", notes = "转评赞系统添加评价")
    public Object addComment(@RequestBody ZpzComment zpzComment) {
        int i = zpzCommentService.addComment(getContext(), zpzComment);
        return Result.success(i);
    }

    @PostMapping("/getCommentList")
    @ApiOperation(value = "请求评论信息接口", notes = "请求评论信息接口")
    public Object getCommentList(@RequestBody SearchCriteriaBase searchCriteriaBase) {
        Map<String, Object> commentList = zpzCommentService.getCommentList(getContext(),searchCriteriaBase);
        return Result.success(commentList);
    }

    @GetMapping("/updateCommentStatus")
    @ApiOperation(value = "屏蔽/审核通过接口", notes = "屏蔽/审核通过接口")
    public Object updateCommentStatus(@RequestParam int commentId, @RequestParam int status) {
        int i = zpzCommentService.updateCommentStatus(getContext(), commentId, status);
        return Result.success(i);
    }

    @PostMapping("/adminCommentList")
    @ApiOperation(value = "请求信息的评论清单接口", notes = "请求信息的评论清单接口")
    public Object getAdminCommentList(@RequestBody CommentListRequest request) {
        Map<String, Object> adminCommentList = zpzCommentService.getAdminCommentList(request.getInFormationId(), request.getType(), request.getPageNo(), request.getPageSize());
        return Result.success(adminCommentList);
    }

}

